﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_Absences : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        private IAbsenceBLL abBLL = new AbsenceBLL();
        private IAbsenceTypeBLL abtypeBLL = new AbsenceTypeBLL();
        private IEmployeeBLL empBLL = new EmployeeBLL();
        private IPositionBLL posBLL = new PositionBLL();
        private IClassBLL classBLL = new ClassBLL();
        private IJobSiteBLL jsBLL = new JobSiteBLL();
        private KPIS.GERP.GHRMS.IBLL.ITreeViewBLL treeBLL = new KPIS.GERP.GHRMS.BLL.TreeViewBLL();

        private AbsenceInfo abInfo = new AbsenceInfo();
        private EmployeeInfo empInfo = new EmployeeInfo();

        private const int ItemsPerRequest = 10;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OnUpdateCmdUI("VIEW");
                PanelPageView1.Visible = false;

                LoadRootNodes(RadTreeView1, TreeNodeExpandMode.ServerSideCallBack);
                RadTreeNode selected_node = RadTreeView1.SelectedNode;
            }
        }

        private void LoadDataGrid()
        {
            //IList<AbsenceInfo> infoList = abBLL.ListAbsences();

            //RadGrid1.DataSource = infoList;
            //RadGrid1.Rebind();
        }
        private static string GetStatusMessage(int offset, int total)
        {
            if (total <= 0)
                return "ไม่มีข้อมูล";

            return String.Format("รายการที่ <b>1</b>-<b>{0}</b> จากทั้งหมด <b>{1}</b> รายการ", offset, total);
        }
        protected void cmbEmployee_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbEmployee.Items.Clear();

            Nullable<int> WorkingJobSite = string.IsNullOrEmpty(cmbWorkingJobSite.SelectedValue) ? (int?)null : Int32.Parse(cmbWorkingJobSite.SelectedValue);

            DataSet ds = empBLL.LoadEmployees((int?)null, "", (int?)null, WorkingJobSite, true, e.Text);
            DataTable dt = ds.Tables[0];

            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
            e.EndOfItems = (endOffset == dt.Rows.Count);
            int j = 0;
            for (int i = itemOffset; i < endOffset; i++)
            {
                cmbEmployee.Items.Add(new RadComboBoxItem(dt.Rows[i]["FULL_NAME"].ToString(), dt.Rows[i]["EMP_SEQ"].ToString()));

                TableRow tr = new TableRow();

                TableCell tdPosName = new TableCell();
                Label lblPosName = new Label();
                lblPosName.Text = dt.Rows[i]["FULL_NAME"].ToString();
                tdPosName.Width = Unit.Pixel(150);
                tdPosName.Controls.Add(lblPosName);
                tr.Cells.Add(tdPosName);

                TableCell tdClassSpecName = new TableCell();
                Label lblClassSpecName = new Label();
                lblClassSpecName.Text = dt.Rows[i]["POS_NAME"].ToString();
                tdClassSpecName.Width = Unit.Pixel(100);
                tdClassSpecName.Controls.Add(lblClassSpecName);
                tr.Cells.Add(tdClassSpecName);

                TableCell tdJobName = new TableCell();
                Label lblJobName = new Label();
                lblJobName.Text = dt.Rows[i]["CLASS_NAME"].ToString();
                tdJobName.Width = Unit.Pixel(100);
                tdJobName.Controls.Add(lblJobName);
                tr.Cells.Add(tdJobName);

                ((Table)cmbEmployee.Items[j].FindControl("tableEmployee")).Controls.Add(tr);
                j++;
            }
            e.Message = GetStatusMessage(endOffset, dt.Rows.Count);
        }
        private void ListAbsenceType()
        {
            IList<AbsenceTypeInfo> infoList = abtypeBLL.ListAbsenceTypes();

            cmbAbsenceType.DataSource = infoList;
            cmbAbsenceType.DataBind();
        }
        private void LoadRootNodes(RadTreeView treeView, TreeNodeExpandMode expandMode)
        {
            IList<TreeViewInfo> infoList = treeBLL.LoadAbsenceTreeView("", "", "");

            foreach (TreeViewInfo info in treeBLL.LoadAbsenceTreeView("", "", ""))
            {
                RadTreeNode node = new RadTreeNode();
                node.Text = info.Name;
                node.ToolTip = info.Descr;
                node.Value = info.Id;
                node.ImageUrl = info.Image_url;
                if (Convert.ToInt32(info.Children_count) > 0)
                {
                    node.ExpandMode = expandMode;
                }
                treeView.Nodes.Add(node);
            }
        }

        private void PopulateNodeOnDemand(RadTreeNodeEventArgs e, TreeNodeExpandMode expandMode)
        {
            //e.Node.Dispose();
            e.Node.Nodes.Clear();

            foreach (TreeViewInfo info in treeBLL.LoadAbsenceTreeView("", "", e.Node.Value))
            {
                RadTreeNode node = new RadTreeNode();
                node.Text = info.Name;
                node.ToolTip = info.Descr;
                node.Value = info.Id;
                node.ImageUrl = info.Image_url;
                if (Convert.ToInt32(info.Children_count) > 0)
                {
                    node.ExpandMode = expandMode;
                }
                e.Node.Nodes.Add(node);
            }

            e.Node.Expanded = true;
            e.Node.ExpandMode = expandMode;
        }

        private void PopulateNodeOnDemand(RadTreeNode node, TreeNodeExpandMode expandMode)
        {
            node.Dispose();
            node.Nodes.Clear();

            foreach (TreeViewInfo info in treeBLL.LoadAbsenceTreeView("", "", node.Value))
            {
                RadTreeNode newNode = new RadTreeNode();
                newNode.Text = info.Name;
                newNode.ToolTip = info.Descr;
                newNode.Value = info.Id;
                newNode.ImageUrl = info.Image_url;
                if (Convert.ToInt32(info.Children_count) > 0)
                {
                    newNode.ExpandMode = expandMode;
                    PopulateNodeOnDemand(newNode, expandMode);
                }
                node.Nodes.Add(newNode);
            }

            node.Expanded = true;
            node.ExpandMode = expandMode;
        }

        public void PopulateNodeOnEditGrid(RadTreeNodeEventArgs e, TreeNodeExpandMode expandMode)
        {
            foreach (TreeViewInfo info in treeBLL.LoadAbsenceTreeView("", "", e.Node.Value))
            {
                RadTreeNode node = new RadTreeNode();
                node.Text = info.Name;
                node.ToolTip = info.Descr;
                node.Value = info.Id;
                node.ImageUrl = info.Image_url;
                if (Convert.ToInt32(info.Children_count) > 0)
                {
                    node.ExpandMode = expandMode;
                }
                e.Node.Nodes.Add(node);
            }

            e.Node.Nodes.Clear();
            e.Node.ExpandMode = expandMode;
        }
        public void RefreshTree()
        {
            RadTreeNode selected_node = RadTreeView1.SelectedNode;
            if (selected_node == null)
            {
                selected_node = RadTreeView1.FindNodeByValue("0");
            }
            RadTreeNodeEventArgs node = new RadTreeNodeEventArgs(selected_node);
            RadAjaxManager1.ResponseScripts.Add(@"CollapseSelectTree();");
            PopulateNodeOnEditGrid(node, TreeNodeExpandMode.ServerSideCallBack);
            RadAjaxManager1.ResponseScripts.Add(@"ExpandSelectTree();");
        }
        //protected void btnExpand_Click(object sender, ImageClickEventArgs e)
        //{
        //    IList<TreeViewInfo> infoList = treeBLL.LoadAbsenceTreeView("", "", "");

        //    RadTreeView1.Nodes.Clear();
        //    RadTreeView1.DataSource = infoList;
        //    RadTreeView1.DataBind();
        //    RadTreeView1.ExpandAllNodes();
        //}
        //protected void btnCollapse_Click(object sender, EventArgs e)
        //{
        //    RadTreeView1.CollapseAllNodes();
        //}
        protected void cmdExpand_Click(object sender, ImageClickEventArgs e)
        {
            foreach (RadTreeNode node in RadTreeView1.Nodes)
            {
                PopulateNodeOnDemand(node, TreeNodeExpandMode.ServerSideCallBack);
            }

            //IList<TreeViewInfo> infoList = treeBLL.LoadAbsenceTreeView("", "", "");

            //RadTreeView1.Nodes.Clear();
            //RadTreeView1.DataSource = infoList;
            //RadTreeView1.DataBind();
            //RadTreeView1.ExpandAllNodes();
        }

        protected void cmdCollapse_Click(object sender, ImageClickEventArgs e)
        {
            RadTreeView1.CollapseAllNodes();
        }

        protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e)
        {
            PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSideCallBack);
        }

        private void OnUpdateCmdUI(string Mode)
        {
            bool bViewMode = Mode == "VIEW";
            bool bAddNewMode = Mode == "ADDNEW";
            bool bEditMode = Mode == "EDIT";

            RadTabStrip1.Tabs[0].Visible = bViewMode;
            RadTabStrip1.Tabs[1].Visible = bViewMode;
            RadTabStrip1.Tabs[2].Visible = !bViewMode;

            if (bViewMode)
            {
                RadTabStrip1.Tabs[0].Selected = true;
                RadPageView1.Selected = true;
            }
            else
            {
                RadTabStrip1.Tabs[2].Selected = true;
                RadPageView3.Selected = true;
            }

            btnAddnew.Visible = !bEditMode;
            btnUpdate.Visible = bEditMode;

            cmdEdit.Visible = bViewMode;
            cmdAddNew.Visible = bViewMode;
            cmdDelete.Visible = !bAddNewMode;

        }

        protected void LoadDataEmployee(string EmpSeq)
        {
            IList<EmployeeInfo> empList = empBLL.ListEmployees(EmpSeq);
            DataSet ds = empBLL.LoadEmployees(Int32.Parse(EmpSeq), "", true, "");
            DataTable dt = null;
            
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    lblName.Text = dt.Rows[0]["FULL_NAME"].ToString();// empInfo.Person.FullName;
                    lblPosRef.Text = dt.Rows[0]["POS_REF"].ToString();//empInfo.Position == null ? "" : empInfo.Position.RefNo;
                    lblPosName.Text = dt.Rows[0]["POS_NAME"].ToString();//empInfo.Position == null ? "" : empInfo.Position.Name;
                    lblClassName.Text = dt.Rows[0]["CLASS_NAME"].ToString();//empInfo.Class == null ? "" : empInfo.Class.Name;
                    lblJobSiteName.Text = dt.Rows[0]["JOB_SITE_NAME"].ToString();//empInfo.Position == null ? "" : empInfo.Position.JobSite.Name;
                    lblWorkingJobSiteName.Text = dt.Rows[0]["WORKING_JOB_SITE_NAME"].ToString();//empInfo.WorkingJobSite == null ? "" : empInfo.WorkingJobSite.Name;
                }
            }

            //if (File.Exists(Server.MapPath("../../OtherImages/Person/" + EmpSeq + ".jpg").Replace("\\", "/")))
            //    imgEmp.ImageUrl = "../../OtherImages/Person/" + EmpSeq + ".jpg";
            //else
            //    imgEmp.ImageUrl = "../../OtherImages/Person/0.jpg";

        }

        protected void LoadDataEmployeeAbsence(int AbsenceSeq)
        {
            DataSet ds = abBLL.LoadAbsences(AbsenceSeq, (int?)null);
            DataTable dt = null;
            if (ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    lblAbsenceType.Text = dt.Rows[0]["ABSENCE_TYPE_NAME"].ToString();// abInfo.AbsenceType.Name;
                    lblReason.Text = dt.Rows[0]["REMARKS"].ToString();//abInfo.Remarks;
                    lblStartDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["START_DATE"]);//string.Format("{0:dd/MM/yyyy}", abInfo.StartDate);
                    lblEndDate.Text = string.Format("{0:dd/MM/yyyy}", dt.Rows[0]["END_DATE"]);//string.Format("{0:dd/MM/yyyy}", abInfo.EndDate);
                    lblCountDate.Text = string.Format("{0:N1}", dt.Rows[0]["COUNT_DATE"]);//string.Format("{0:N1}", abInfo.CountDate);
                    //lblLastAbsence.Text = ds.Tables[0].Rows[0]["LAST_ABSENCE"].ToString();
                    //lblLastStartDate.Text = string.Format("{0:dd/MM/yyyy}", ds.Tables[0].Rows[0]["LAST_START_DATE"]);
                    //lblLastEndDate.Text = string.Format("{0:dd/MM/yyyy}", ds.Tables[0].Rows[0]["LAST_END_DATE"]);
                    //lblLastDayCount.Text = string.Format("{0:N1}", ds.Tables[0].Rows[0]["LAST_DAY_COUNT"]);
                    lblContactAddress.Text = dt.Rows[0]["CONTACT_ADDRESS"].ToString();// abInfo.ContactAddress;

                    //// Load data to control
                    cmbStatus.SelectedValue = dt.Rows[0]["APPROVED_STATUS"].ToString();//abInfo.Status;
                    cmbEmployee.Items.Add(new RadComboBoxItem(dt.Rows[0]["FULL_NAME"].ToString(), dt.Rows[0]["EMP_SEQ"].ToString()));
                    cmbEmployee.SelectedValue = dt.Rows[0]["EMP_SEQ"].ToString();//
                    FillDataToApproved();
                    cmbAbsenceType.SelectedValue = dt.Rows[0]["ABSENCE_TYPE_SEQ"].ToString();//

                    txtStartDate.SetValue(dt.Rows[0]["START_DATE"]);
                    rdoStartTime.SelectedValue = dt.Rows[0]["START_TIME"].ToString();
                    txtEndDate.SetValue(dt.Rows[0]["END_DATE"]);
                    rdoEndTime.SelectedValue = dt.Rows[0]["END_TIME"].ToString();
                    txtCountDate.Text = string.Format("{0:N1}", dt.Rows[0]["COUNT_DATE"]);
                    txtContactAddress.Text = dt.Rows[0]["CONTACT_ADDRESS"].ToString();
                    txtReason.Text = dt.Rows[0]["REMARKS"].ToString();
                    cmbApprovedBy.SelectedValue = dt.Rows[0]["APPROVED_BY"].ToString();
                    txtApprovedPosition.Text = dt.Rows[0]["APPROVED_POSITION"].ToString();
                    txtApprovedDate.SetValue(dt.Rows[0]["APPROVED_DATE"]);
                }
            }
        }

        protected void LoadDataAbsenceStat()
        {
            //DataSet ds = Absences.LoadGridAbsencesByEmp(1);

            //if (ds.Tables[0].Rows.Count > 0)
            //{
            //lblSickTotal.Text = "0"; // ds.Tables[0].Rows[0]["EMP_TYPE_NAME"].ToString();
            //lblSickCount.Text = "0"; //ds.Tables[0].Rows[0]["POS_TYPE_NAME"].ToString();
            //    lblSickCountSum.Text = ds.Tables[0].Rows[0]["FIELD_GROUP_DESCR"].ToString();
            //    lblPrivateTotal.Text = ds.Tables[0].Rows[0]["CLASS_SPEC_NAME"].ToString();
            //    lblPrivateCount.Text = ds.Tables[0].Rows[0]["FIELD_POS_NAME"].ToString();
            //    lblPrivateCountSum.Text = ds.Tables[0].Rows[0]["FIELD_POS_NAME_ENG"].ToString();
            //    lblTotal.Text = ds.Tables[0].Rows[0]["FIELD_POS_LINE"].ToString();
            //    lblCount.Text = ds.Tables[0].Rows[0]["FIELD_POS_LINE"].ToString();
            //    lblSum.Text = ds.Tables[0].Rows[0]["FIELD_POS_LINE"].ToString();
            //}

        }

        protected void UpdateControl()
        {
            ListAbsenceType();
            PanelPageView1.Visible = false;
            // Panel Employees
            lblName.Text = "";
            lblPosRef.Text = "";
            lblPosName.Text = "";
            lblClassName.Text = "";
            lblJobSiteName.Text = "";
            lblWorkingJobSiteName.Text = "";
            //imgEmp.ImageUrl = "../../OtherImages/Person/0.jpg";
            //cmbEmpSeq.SelectedIndex = 0;

            //// Panel AbsenceDetail
            lblAbsenceType.Text = "";
            lblReason.Text = "";
            lblStartDate.Text = "";
            lblEndDate.Text = "";
            lblCountDate.Text = "";
            //lblLastAbsence.Text = "";
            //lblLastStartDate.Text = "";
            //lblLastEndDate.Text = "";
            //lblLastDayCount.Text = "";
            lblContactAddress.Text = "";

            cmbStatus.SelectedIndex = -1;
            //cmbEmployee.SelectedValue = string.Empty;
            cmbAbsenceType.SelectedValue = string.Empty;
            txtStartDate.SetValue("");
            rdoStartTime.SelectedIndex = 0;
            txtEndDate.SetValue("");
            rdoEndTime.SelectedIndex = 0;
            txtCountDate.Text = "";
            txtContactAddress.Text = "";
            txtReason.Text = "";
            cmbApprovedBy.SelectedIndex = 0;
            txtApprovedPosition.Text = "";
            txtApprovedDate.SetValue("");
        }
        
        protected void FillDataToApproved()
        {
            cmbApprovedBy.Items.Clear();

            UpperComboBLL obj = new UpperComboBLL();
            DataTable dataTable = new DataTable();
            dataTable = obj.ListUpperPosition(Int32.Parse(cmbEmployee.SelectedValue), 1, 0);
            if (dataTable != null)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    RadComboBoxItem item = new RadComboBoxItem();

                    item.Text = (string)dataRow["FULL_NAME"];
                    item.Value = dataRow["EMP_SEQ"].ToString();

                    item.Attributes.Add("FULL_NAME", (string)dataRow["FULL_NAME"]);
                    item.Attributes.Add("EXEC_POS_NAME", (string)dataRow["EXEC_POS_NAME"]);
                    item.Attributes.Add("CLASS_NAME", (string)dataRow["CLASS_NAME"]);

                    item.Value += ":" + (string)dataRow["EXEC_POS_NAME"];

                    cmbApprovedBy.Items.Add(item);
                    item.DataBind();
                }
            }
        }
        protected void cmbApprovedBy_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            FillDataToApproved();
        }
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            LoadDataGrid();
        }

        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            abBLL.Insert(cmbAbsenceType.SelectedValue
                , cmbEmployee.SelectedValue
                , DateTime.Parse(txtStartDate.GetStringValue())
                , rdoStartTime.SelectedValue
                , DateTime.Parse(txtEndDate.GetStringValue())
                , rdoEndTime.SelectedValue
                , decimal.Parse(txtCountDate.Text)
                , txtContactAddress.Text.Trim()
                , cmbStatus.SelectedValue
                , cmbApprovedBy.SelectedValue
                , txtApprovedPosition.Text.Trim()
                , txtApprovedDate.GetStringValue().Length > 0 ? DateTime.Parse(txtApprovedDate.GetStringValue()) : (DateTime?)null             
                , txtReason.Text.Trim()
                , ssMng.EmpSeqI);

            UpdateControl();
            OnUpdateCmdUI("VIEW");            
            RefreshTree();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            abBLL.Update(Int32.Parse(lblSequence.Text.Trim())
                , cmbAbsenceType.SelectedValue
                , cmbEmployee.SelectedValue
                , DateTime.Parse(txtStartDate.GetStringValue())
                , rdoStartTime.SelectedValue
                , DateTime.Parse(txtEndDate.GetStringValue())
                , rdoEndTime.SelectedValue
                , decimal.Parse(txtCountDate.Text)
                , txtContactAddress.Text.Trim()
                , cmbStatus.SelectedValue
                , cmbApprovedBy.SelectedValue
                , txtApprovedPosition.Text.Trim()
                , txtApprovedDate.GetStringValue().Length > 0 ? DateTime.Parse(txtApprovedDate.GetStringValue()) : (DateTime?)null
                , txtReason.Text.Trim()
                , ssMng.EmpSeqI);

            UpdateControl();
            OnUpdateCmdUI("VIEW");
            RefreshTree();
            //LoadDataEmployeeAbsence(Int32.Parse(lblAbsenceSeq.Text.Trim()));
        }
        
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            OnUpdateCmdUI("VIEW");
            UpdateControl();
        }

        protected void cmbEmpSeq_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            //LoadDataEmployee(cmbEmpSeq.SelectedValue);
        }

        protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            RadTreeNode selected_node = RadTreeView1.SelectedNode;

            string value = selected_node.Value;
            string name = selected_node.Text.Trim();
            string[] root_value = selected_node.Value.Split(new string[] { "-" }, StringSplitOptions.None);            

            if (!string.IsNullOrEmpty(value))
            {
                lblSequence.Text = "";

                if (selected_node.Level == 2)
                {                   
                    lblSequence.Text = value.ToString();
                    IList<AbsenceInfo> list = abBLL.ListAbsencesBySequence(Int32.Parse(lblSequence.Text));

                    LoadDataEmployeeAbsence(Int32.Parse(lblSequence.Text));
                    LoadDataEmployee(list[0].Employee.Sequence.ToString());
                }
            }

            OnUpdateCmdUI("VIEW");
            PanelPageView1.Visible = selected_node.Level == 2;
            
        }
        protected void cmbWorkingJobSite_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            cmbWorkingJobSite.Items.Clear();

            DataSet ds = jsBLL.LoadJobSiteSearchText(SystemInfo._JobsiteExternal, "", e.Text);
            DataTable dt = ds.Tables[0];

            int itemOffset = e.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, dt.Rows.Count);
            e.EndOfItems = (endOffset == dt.Rows.Count);
            int j = 0;
            for (int i = itemOffset; i < endOffset; i++)
            {
                cmbWorkingJobSite.Items.Add(new RadComboBoxItem(dt.Rows[i]["JOB_SITE_NAME"].ToString(), dt.Rows[i]["JOB_SITE_SEQ"].ToString()));

                TableRow tr = new TableRow();
                TableCell tdFieldName = new TableCell();
                Label lblFieldName = new Label();
                lblFieldName.Text = dt.Rows[i]["JOB_SITE_NAME"].ToString();
                tdFieldName.Width = Unit.Pixel(300);
                tdFieldName.Controls.Add(lblFieldName);
                tr.Cells.Add(tdFieldName);

                ((Table)cmbWorkingJobSite.Items[j].FindControl("tableNewJobSite")).Controls.Add(tr);
                j++;
            }
            e.Message = GetStatusMessage(endOffset, dt.Rows.Count);
        }
        protected void cmdSearch_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void cmdAddNew_Click(object sender, EventArgs e)
        {
            OnUpdateCmdUI("ADDNEW");
            UpdateControl();
        }

        protected void cmdEdit_Click(object sender, EventArgs e)
        {
            OnUpdateCmdUI("EDIT");
            UpdateControl();
            LoadDataEmployeeAbsence(Int32.Parse(lblSequence.Text.Trim()));
        }

        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            abBLL.Delete(Int32.Parse(lblSequence.Text.Trim())
                , ssMng.EmpSeqI);
            OnUpdateCmdUI("VIEW");
            UpdateControl();
            //PopulateNodeOnEditGrid(node, TreeNodeExpandMode.ServerSideCallBack);
            //RadAjaxManager1.ResponseScripts.Add(@"ExpandSelectTree();");
            RefreshTree();
        }

        protected void cmbEmployee_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            FillDataToApproved();
        }

        protected void cmbWorkingJobSite_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RefreshTree();
        }
        
    }
}
